<template>
  <!-- 宿舍调换记录页面 -->
  <div class="app-container">
    <!-- 搜索 -->
    <searchForm
      :formOptions="formOptions"
      @onSearch="onSearch"
      @onReset="onReset"
      v-show="showSearch"
      :formLabelWidth="formLabelWidth"
    />
    <el-row :gutter="10" class="mb8">
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <el-table :data="tableData">
      <el-table-column prop="name" label="学号" align="center">
      </el-table-column>
      <el-table-column prop="name" label="姓名" align="center">
      </el-table-column>
      <el-table-column prop="name" label="院系" align="center">
      </el-table-column>
      <el-table-column prop="name" label="专业" align="center">
      </el-table-column>
      <el-table-column prop="date" label="公寓楼" align="center">
      </el-table-column>
      <el-table-column prop="name" label="房间号" align="center">
      </el-table-column>
      <el-table-column prop="name" label="床位号" align="center">
      </el-table-column>
      <el-table-column prop="name" label="退宿时间" align="center">
      </el-table-column>
      <el-table-column prop="name" label="操作人" align="center">
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import searchForm from "../../components/Search/searchForm.vue";
export default {
  components: { searchForm },
  data() {
    return {
      showSearch: true,
      formLabelWidth: "70px",
      formOptions: [
        {
          label: "学号",
          prop: "XH",
          placeholder: "请输入学号",
          element: "el-input",
        },
        {
          label: "姓名",
          prop: "XM",
          placeholder: "请输入姓名",
          element: "el-input",
        },
        {
          label: "院系",
          prop: "YX",
          placeholder: "请输入院系",
          element: "el-input",
        },
        {
          label: "专业",
          prop: "ZY",
          placeholder: "请输入专业",
          element: "el-input",
        },
        {
          label: "公寓楼",
          prop: "GYL",
          placeholder: "请输入公寓楼",
          element: "el-input",
        },
        {
          label: "操作人",
          prop: "CZR",
          placeholder: "请输入操作人",
          element: "el-input",
        },
      ],
      tableData: [],
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        roleName: undefined,
        roleKey: undefined,
        status: undefined,
        CH: undefined,
        FJH: undefined,
        LH: undefined,
        XH: undefined,
      },
    };
  },
  methods: {
    // 获取搜索表单提交的数据
    onSearch(val) {
      // 查询条件和分页数据合并
      const arr = Object.assign(this.queryParams, val);
      console.log(arr);
      this.queryParams.pageNum = 1;
      this.getList();
    },
     // 重置
     onReset(data) {
      console.log(data);
      this.queryParams.pageNum = 1;
      const arr = Object.assign(this.queryParams, data);
      console.log(this.queryParams);
      this.getList();
    },
    /** 查询角色列表 */
    getList() {
      this.loading = true;
      listRole(this.addDateRange(this.queryParams, this.dateRange)).then(
        (response) => {
          this.tableData = response.rows;
          this.total = response.total;
        }
      );
    },
  },
};
</script>

<style>
</style>